STEP 16: Now let's set the vertical speed. Remember, commands INSIDE events have a green block next to them.

  • From the section, drag Set y Speed INSIDE the space_bar() event. It should have a green block next to it, like this: ····
  • Change the number in the .set_y_speed() command to 2.
  • Change the name in front of .set_y_speed() to rock.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("moon") sprite = codesters.Sprite("astronaut1") sprite.go_to(-125, -150) glorp = codesters.Sprite("alien1") glorp.go_to(100, -125) rock = codesters.Sprite("asteroid") rock.go_to(100, 75) sprite.say("What do planets read?") sprite.set_say_color("white") def click(sprite): sprite.say("Comet books!") sprite.turn_left(360) # add other actions... sprite.event_click(click) def space_bar(): rock.set_x_speed(5) # add other actions... stage.event_key("space", space_bar)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)